package com.project.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author(王思翰)
 * @Description(类的描述)
 * @Date(创建时间) 2021/7/21 10:19
 */
@Controller
@RequestMapping("/user")
public class UserController {

    //形如/user/del/1 的URL，由当前方法处理
    //将URL中的1赋值在userId变量，然后将userId变量的值赋予形参变量id
    @RequestMapping("/del/{userId}")
    public void del(@PathVariable("userId") int id, HttpServletResponse response) throws IOException {
        response.setContentType("text/html;charset=utf-8");
        response.getWriter().println(id);
    }

    @RequestMapping("cutPage")
    public void cutPage(@RequestParam(value = "page",defaultValue = "1") int page, HttpServletResponse response) throws IOException {
        response.getWriter().println(page);
    }
}
